<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8"/>
        <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
        <meta http-equiv="X-UA-Compatible" content="ie=edge"/>
        <title>Document</title>
        <script>

/*         http://localhost/code14/jsonp/01%E5%9B%9E%E9%A1%BEajax.html
        http://localhost/code14/jsonp/1.txt */
            window.onload = function(){
                var oBtn = document.getElementById("btn1");
                oBtn.onclick = function(){
                    var xhr = new XMLHttpRequest();

                    xhr.open("get", "1.txt", true);

                    xhr.send();

                    xhr.onreadystatechange = function(){
                        if(xhr.readyState == 4){
                            alert(xhr.responseText);
                        }
                    }
                }
            }
        </script>
    </head>
    <body>
        <button id = 'btn1'>下载数据</button>
    </body>
</html>